// ES5 
// filter为“过滤”、“筛选”之意。指数组filter后，返回过滤后的新数组
// array.filter(callback,[ thisObject]);
var names = ['Will', 'Jack', 'Peter', 'Steve', 'John', 'Hugo', 'Mike']; 
var newSet = names.map(function (name, index) { 
    return { 
        id: index, name: name 
    }; 
}).filter(function (man) { 
    return man.id % 2 == 0; 
}).map(function (man) { 
    return [man.name]; 
}).reduce(function (a, b) { 
    return a.concat(b); 
}); 

console.log(newSet); // ["Will", "Peter", "John", "Mike"] 

// ES6 
const names = ['Will', 'Jack', 'Peter', 'Steve', 'John', 'Hugo', 'Mike']; 
const newSet = names.map(
    (name, index) => (
        { 
            id: index, 
            name: name 
        }
    )
).filter(
    man => man.id % 2 == 0
).map(
    man => [man.name]
).reduce(
    (a, b) => a.concat(b)
); 

console.log(newSet); // ["Will", "Peter", "John", "Mike"]